<template>
	<view class="authentication">
		<!-- 师傅 认证 -->
		<u-navbar leftIconSize="34rpx" autoBack :placeholder="true" bgColor="#ffffff">
			<view class="" slot="center">
				<text class="c-000 pf-sc fw-600" style="font-size: 34rpx;">申请合伙人</text>
			</view>
		</u-navbar>
		<!-- 未提交 -->
		<view
			class="authentication-container w-750 b-box d-flex flex-c just-sw ali-i-c  bg-fa po-re"
			:style="{ height: containerHeight }"
			v-if="NoSubmit"
		>
			<view>
				<!-- 表单 -->
				<view class="w-750 bg-ff b-box p-x-32" style="margin-bottom: 22rpx;padding-top: 32rpx;">
					<!-- 入住名称 -->
					<view
						class="d-flex flex-r ali-i-c just-c b-box"
						style="border-bottom: 2rpx solid #EEEEEE;padding: 34rpx 0;"
					>
						<text
							class="pf-sc fw-400"
							style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 48rpx;"
						>
							入住名称
						</text>
						<u-input
							border="none"
							placeholder="请输入入住名称"
							:customStyle="{ color: 'rgba(0,0,0,0.9000)', font: '400 30rpx PingFang SC' }"
							placeholderStyle="color:#999999;fontWeight:400;fontsize:30px;fontfamily:PingFang SC-Regular, PingFang SC"
							v-model="requetParams.name"
						></u-input>
					</view>
				<!-- 入住人身份 -->
					<view class="d-flex flex-r ali-i-c just-c b-box" style="padding: 34rpx 0;">
						<text
							class="pf-sc fw-400"
							style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 18rpx;"
						>
							入住人身份
						</text>
						<u-input
							type="text"
							border="none"
							placeholder="请输入入住人身份"
							placeholderStyle="color:#999999;fontWeight:400;fontsize:30px;fontfamily:PingFang SC-Regular, PingFang SC"
							:customStyle="{ color: 'rgba(0,0,0,0.9000)', font: '400 30rpx PingFang SC' }"
							v-model="requetParams.identity"
						></u-input>
					</view>
					<!-- 法人姓名 -->
					<view class="d-flex flex-r ali-i-c just-c b-box" style="padding: 34rpx 0;">
						<text
							class="pf-sc fw-400"
							style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 48rpx;"
						>
							法人姓名
						</text>
						<u-input
							type="text"
							border="none"
							placeholder="请输入入法人姓名"
							placeholderStyle="color:#999999;fontWeight:400;fontsize:30px;fontfamily:PingFang SC-Regular, PingFang SC"
							:customStyle="{ color: 'rgba(0,0,0,0.9000)', font: '400 30rpx PingFang SC' }"
							v-model="requetParams.username"
						></u-input>
					</view>
					<!-- 手机号 -->
					<view class="d-flex flex-r ali-i-c just-c b-box" style="padding: 34rpx 0;">
						<text
							class="pf-sc fw-400"
							style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 78rpx;"
						>
							手机号
						</text>
						<u-input
							type="number"
							border="none"
							placeholder="请输入手机号"
							placeholderStyle="color:#999999;fontWeight:400;fontsize:30px;fontfamily:PingFang SC-Regular, PingFang SC"
							:customStyle="{ color: 'rgba(0,0,0,0.9000)', font: '400 30rpx PingFang SC' }"
							v-model="requetParams.phone"
						></u-input>
					</view>
					<!-- 所在地区 -->
					<view class="d-flex flex-r ali-i-c just-c b-box" style="padding: 34rpx 0;">
						<text
							class="pf-sc fw-400"
							style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 48rpx;"
						>
							所在地区
						</text>
						<u-input
							type="text"
							border="none"
							placeholder="请输入所在地区的省/市/区/县"
							placeholderStyle="color:#999999;fontWeight:400;fontsize:30px;fontfamily:PingFang SC-Regular, PingFang SC"
							:customStyle="{ color: 'rgba(0,0,0,0.9000)', font: '400 30rpx PingFang SC' }"
							v-model="requetParams.region"
						></u-input>
					</view>
					
					<!-- 详细地址 -->
					<view class="d-flex flex-r ali-i-c just-c b-box" style="padding: 34rpx 0;">
						<text
							class="pf-sc fw-400"
							style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 48rpx;"
						>
							详细地址
						</text>
						<u-input
							type="text"
							border="none"
							placeholder="街道、楼牌号等"
							placeholderStyle="color:#999999;fontWeight:400;fontsize:30px;fontfamily:PingFang SC-Regular, PingFang SC"
							:customStyle="{ color: 'rgba(0,0,0,0.9000)', font: '400 30rpx PingFang SC' }"
							v-model="requetParams.address"
						></u-input>
					</view>
					
					
					
					
				</view>
				<!-- 上传 -->
				<view class="w-750 bg-ff b-box p-x-32" style="padding-top: 32rpx; margin-bottom:60rpx">
					<view
						class="d-flex flex-r ali-i-c just-c b-box"
						style="border-bottom: 2rpx solid #EEEEEE;padding: 34rpx 0;"
					>
						<view class="d-flex flex-c ali-i-s just-s " style="width: 164rpx;">
							<text
								class="pf-sc fw-400"
								style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 0rpx;"
							>
								门店照片
							</text>
							<text
								class="pf-sc fw-400"
								style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 0rpx;"
							>
								或营业执照
							</text>
						</view>
						<u-upload
							width="126rpx"
							height="126rpx"
							:fileList="fileList1"
							@afterRead="afterRead"
							@delete="deletePic"
							name="1"
							multiple
							:maxCount="1"
							:customStyle="{ marginRight: '40rpx' }"
						>
							<image
								:src="require('../static/add.png')"
								mode="widthFix"
								style="width: 126rpx;height: 126rpx;"
							></image>
						</u-upload>
					</view>
					<view class="d-flex flex-r ali-i-c just-c b-box" style="padding: 34rpx 0;">
						<view class="d-flex flex-c ali-i-s just-s " style="width: 164rpx;">
							<text
								class="pf-sc fw-400"
								style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 0rpx;"
							>
								身份证
							</text>
							<text
								class="pf-sc fw-400"
								style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-right: 0rpx;"
							>
								正反面
							</text>
						</view>
						<u-upload
							width="126rpx"
							height="126rpx"
							:customStyle="{ marginRight: '40rpx' }"
							:fileList="fileList2"
							@afterRead="afterRead2"
							@delete="deletePic"
							name="2"
							multiple
							:maxCount="2"
						>
							<image
								:src="require('../static/add.png')"
								mode="widthFix"
								style="width: 126rpx;height: 126rpx;"
							></image>
						</u-upload>
					</view>
				</view>
				<!-- 提交 -->
				<view class="w-750 b-box" style="padding: 0px 40rpx 80rpx 40rpx;">
					<u-button
						:throttleTime="700"
						@click="Submit"
						:customStyle="{
							height: '88rpx',
							width: '670rpx',
							font: '500 32rpx PingFang SC',
							color: '#ffffff',
							background: 'linear-gradient(180deg, #4885C5 0%, #3B52A6 100%)',
							borderRadius: '44rpx'
						}"
						shape="square"
						text="提交"
					></u-button>
				</view>
			</view>
			<!-- 联系客服 -->
			<view
				class="w-750 b-box d-flex flex-r ali-i-c just-c po-ab"
				style="bottom: -140rpx;left: 0;right: 0;"
			>
				<view class="d-flex flex-r ali-i-c just-c" @click="ContactService">
					<view style="width: 38rpx;height: 38rpx;margin-right:12rpx">
						<image :src="require('../static/kefu.png')" style="width: 38rpx;height: 38rpx;"></image>
					</view>
					<text class="pf-sc fw-400 " style="color: #999999;font-size: 30rpx;">联系客服</text>
				</view>
			</view>
		</view>
		<!-- 已提交 -->
	</view>
</template>

<script>
import Unavbar from '../components/uview-ui/components/u-navbar/u-navbar';
import Uinput from '../components/uview-ui/components/u-input/u-input';
import Ubutton from '../components/uview-ui/components/u-button/u-button';
import { _containerHeight } from '@/utils/GetSys.js';
export default {
	components: {
		'u-navbar': Unavbar,
		'u-input': Uinput,
		'u-button': Ubutton
	},
	data() {
		return {
			containerHeight: '',
			NoSubmit: true,
			SubmitStatus: 0, //0:已提交；1：审核中；2，审核通过
			requetParams: {
				name:'',//名称
       identity:'',//身份
			 username:'',//名字
			 phone:"",//手机
			 region:"",//所在地区
			 address:""//详细地址
			},
			fileList1: [], //营业执照
			fileList2: [] //身份证正反面
		};
	},
	methods: {
		GoLogOn() {
			uni.redirectTo({
				url: `/staffModelA/staffB/LogOn/LogOn`
			});
		},
		ContactService() {},
		Submit() {
			this.NoSubmit = false;
			this.SubmitStatus = 0;
		},
		// 删除图片
		deletePic(event) {
			this[`fileList${event.name}`].splice(event.index, 1);
		},
		async afterRead(event) {
			let lists = [].concat(event.file);
			let fileListLen = this[`fileList${event.name}`].length;
			lists.map(item => {
				this[`fileList${event.name}`].push({
					...item,
					status: 'uploading',
					message: '上传中'
				});
			});
			for (let i = 0; i < lists.length; i++) {
				const result = await this.uploadFilePromise(lists[i].url);
				let item = this[`fileList${event.name}`][fileListLen];
				this[`fileList${event.name}`].splice(
					fileListLen,
					1,
					Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					})
				);
				fileListLen++;
			}
		},
		async afterRead2(event) {
			let lists = [].concat(event.file);
			let fileListLen = this[`fileList${event.name}`].length;
			lists.map(item => {
				this[`fileList${event.name}`].push({
					...item,
					status: 'uploading',
					message: '上传中'
				});
			});
			for (let i = 0; i < lists.length; i++) {
				const result = await this.uploadFilePromise(lists[i].url);
				let item = this[`fileList${event.name}`][fileListLen];
				this[`fileList${event.name}`].splice(
					fileListLen,
					1,
					Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					})
				);
				fileListLen++;
			}
		},
		uploadFilePromise(url) {
			return new Promise((resolve, reject) => {
				let a = uni.uploadFile({
					url: 'http://192.168.2.21:7001/upload',
					filePath: url,
					name: 'file',
					formData: {
						user: 'test'
					},
					success: res => {
						setTimeout(() => {
							resolve(res.data.data);
						}, 1000);
					}
				});
			});
		}
	},
	onLoad() {
		this.containerHeight = _containerHeight();
		// this.NoSubmit=false; //true:用户首次提交 false:用户已经提交一次
		// this.SubmitStatus=2
	}
};
</script>

<style lang="scss">
.authentication {
	.authentication-container {
	}
}
</style>
